<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<script type='text/javascript'
			src='dwr/interface/schoolingManageService.js'></script>
		<script type='text/javascript' src='dwr/engine.js'></script>
		<script type='text/javascript' src='dwr/util.js'></script>
		<!--[if !IE]><!-->
  			<script type='text/javascript' src=' js/main_body_displaytimetable.js'></script>
  		<!--<![endif]-->
  		<!--[if IE]>
  			<script type='text/javascript' src=' js/main_body_displaytimetable_ie.js'></script>
  		<![endif]-->
		<link rel="stylesheet" type="text/css" href="css/main_body_displaytimetable.css">
		<style type="text/css">
			#title{
				margin-top:15px;
			}
			#table_result table{
                font-family:Georgia, "Times New Roman", Times, serif;
                border: 1px solid #555;
                color: #555;
                border-collapse: collapse;
            }
           #table_result table tr{
                	border: 1px solid #555;
                	color: #555;
            }
            #table_result table th{
                	border: 1px solid #555;
                	color: #555;
            }
           #table_result table td{
                    border: 1px solid #555;
                    color: #555;
            }
		</style>
		<SCRIPT type="text/javascript">
				function check_table(){
					var courseName = document.getElementById('chooseCourse').value;
					var instructorName = document.getElementById('chooseInstructor').value;
					if(courseName==-1||instructorName==-1){						
							return false;
						}
					return true;
					}
		</SCRIPT>
</head>
<body>
	<div id="main">
		<!-- 添加保存授课单 ,#request.add 为动作类保存到request的变量,以致减少jsp页面-->
		<s:if test="#request.add != null ">
			<div id="title">
			<h4>
				<s:text name="timetable.text.save.save.schooling.table" />
			</h4></div><hr />
			<div id="select">
			<p><s:text name="timetable.text.save.please.select.course.and.instructor.first" /></p>
			<s:form action="schooling_manage/saveTimeTable.action" onsubmit="return check_table();">
				<s:select id="chooseCourse" key="timetable.form.save.course" name="schoolingInstructorCourse.ts_cno.cno"
					list="#request.CourseNames" listKey="cno" listValue="name" headerKey="-1" headerValue="Select Course"  value="%{#request.courseId}"
					onchange="showCourseDetail()" />

				<s:select id="chooseInstructor" key="timetable.form.save.instructor"  name="schoolingInstructorCourse.im_ino.id"
					list="#request.InstructorNames" listKey="id" listValue="name" headerKey="-1" headerValue="Select Instructor" value=""
					onchange="showInstructorDetail()"/>
				<s:textfield id="place"  name="schoolingInstructorCourse.place" key="timetable.form.save.place"  onchange="showPlaceDetail()" value="%{#request.instructorId}" ></s:textfield>
				<s:textfield id="date"  name="schoolingInstructorCourse.date" key="timetable.form.save.date"  onchange="showDateDetail()" value="" ></s:textfield>
				
				<s:hidden id="cname_hidden" name="schoolingInstructorCourse.courseName" value=""></s:hidden>
				<s:hidden id="instructor_hidden" name="schoolingInstructorCourse.instructorName" value=""></s:hidden>
				<s:submit key="timetable.form.save.submit"/>
			</s:form>
			<div><s:if test="#request.savesuccess != null "><h4><s:text name="timetable.text.save.save.success" /></h4></s:if></div>
			</div>
			<div id="detail">
				<p><b><s:text name="timetable.text.save.detail" /></b></p>
				<div id="showCourseDetail">
					<s:text name="timetable.text.save.waiting.for.your.select" />
				</div>
				<div id="showInstructorDetail"></div>
				<div id="showPlaceDetail"></div>
				<div id="showDateDetail"></div>
				
			</div>
		</s:if>
		<!-- 查询授课单 -->
		<s:if test="#request.search != null ">
				
			<s:if test="#request.delete != null">
				<div id="title"><h4><s:text name="timetable.text.delete.delete.schooling.table" /></h4></div>
			</s:if>
			<s:else>
				<div id="title"><h4><s:text name="timetable.text.search.search.schooling.table" /></h4></div>
			</s:else>
			<hr />
			<s:if test="#request.delete != null">
				<h5><s:text name="timetable.text.delete.before.you.delete.schooling.table" /></h5>
			</s:if>
			<s:if test="#request.beforemodify != null ">
				<h5><s:text name="timetable.text.modify.before.you.modify.schooling.table" /></h5>
			</s:if>
			<div id="searchForm">
			<s:form action="schooling_manage/searchTimeTable.action" method="post" theme="simple">                     
		           <s:submit id="sbutton"  value="Search" />
		           <s:textfield id="ssearchtext"  name="searchText" size="22"/>
		           <div id="searchcheck">
		           		<s:radio name="searchRadio" list="#{'all':'all','cno':'cno','ino':'ino','blear':'blear'}" value="'all'" />
		           </div>
             </s:form>	
             </div>		
             	<s:if test="#request.deletesuccess != null"><h4><s:text name="timetable.text.delete.delete.success" /></h4></s:if>
             	<s:if test="#request.modifysuccess != null"><h4><s:text name="timetable.text.modify.modify.success" /></h4></s:if>
             	<s:if test="#request.searchhavedata != null ">
					<div id="table_result">
             		<table id="searchTable" border="1">
					<tr>					
						<th><s:text name="timetable.text.search.sid" /></th>
						<th><s:text name="timetable.text.search.course" /></th>
						<th><s:text name="timetable.text.search.instructor" /></th>
						<th><s:text name="timetable.text.search.place" /></th>
						<th><s:text name="timetable.text.search.time" /></th>
						<s:if test="%{#session.SESSION_USERTYPE != 'instructor'}"><th><s:text name="timetable.text.search.modify" /></th></s:if>
						<s:if test="%{#session.SESSION_USERTYPE != 'instructor'}"><th><s:text name="timetable.text.search.delete" /></th></s:if>
					</tr>
					<s:iterator  value="#request.allTimeTable">
						<tr>
							<td><span id="sid"><s:property value="sid"/></span></td>
							<td id="courseName"><s:property value="courseName"/></td>
							<td id="instructorName"><s:property value="instructorName"/></td>
							<td id="place"><s:property value="place"/></td>
							<td id="date"><s:property value="date"/></td>
							<s:if test="%{#session.SESSION_USERTYPE != 'instructor'}"><td><button id="sbutton" onclick="modifyTimeTable('<s:property value="sid"/>','<s:property value="ts_cno.cno"/>','<s:property value="im_ino.id"/>','<s:property value="courseName"/>','<s:property value="instructorName"/>','<s:property value="place"/>','<s:property value="date"/>');">Modify</button></td></s:if>
							<s:if test="%{#session.SESSION_USERTYPE != 'instructor'}"><td><button id="sbutton" onclick="deleteTimeTable('<s:property value="sid"/>');">Delete</button></td></s:if>
						</tr>
					</s:iterator>	
					</table>
					</div>						
				
				</s:if>
             	<s:if test="#request.searchnodata != null ">
             		<div id="nodata"><h4><s:text name="timetable.text.search.no.data" /></h4></div>
             	</s:if>
		</s:if>
		 <!-- 修改授课单, -->
           <s:if test="#request.modify != null ">
             	<div id="title"><h4>
				<s:text name="timetable.text.modify.modify.schooling.table" />
			</h4></div><hr />
			<div id="select">
			<p><s:text name="timetable.text.modify.please.modify.course.and.instructor.first" /></p>
			<s:form action="schooling_manage/modifyTimeTable.action">
				<s:select id="chooseCourse" key="timetable.form.save.course" name="schoolingInstructorCourse.ts_cno.cno"
					list="#request.CourseNames" listKey="cno" listValue="name" headerKey="-1" headerValue="Select Course"  value="%{#request.courseId}"
					onchange="showCourseDetail()" />
				<s:select id="chooseInstructor" key="timetable.form.save.instructor" name="schoolingInstructorCourse.im_ino.id"
					list="#request.InstructorNames" listKey="id" listValue="name" headerKey="-1" headerValue="Select Instructor" value="%{#request.instructorId}"
					onchange="showInstructorDetail()"/>
				<s:textfield id="place"  name="schoolingInstructorCourse.place" key="timetable.form.save.place" onchange="showPlaceDetail()" value="%{#request.place}" ></s:textfield>
				<s:textfield id="date"  name="schoolingInstructorCourse.date" key="timetable.form.save.date" onchange="showDateDetail()" value="%{#request.date}" ></s:textfield>
				<s:hidden id="cname_hidden" name="schoolingInstructorCourse.courseName" value="%{#request.courseName}"></s:hidden>
				<s:hidden id="instructor_hidden" name="schoolingInstructorCourse.instructorName" value="%{#request.instructorName}"></s:hidden>
				<s:hidden name="schoolingInstructorCourse.sid" value="%{#request.sid}"></s:hidden>
				<s:submit key="timetable.form.save.submit"/>
			</s:form>
			</div>
			<div id="detail">
				<p><b><s:text name="timetable.text.save.detail" /></b></p>
				<div id="showCourseDetail">
					<s:text name="timetable.text.save.waiting.for.your.select" />
				</div>
				<div id="showInstructorDetail"></div>
				<div id="showPlaceDetail"></div>
				<div id="showDateDetail"></div>
			</div>
             </s:if>
	</div>
</body>
</html>
